package collection.stream;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

public class StreamApiDemo2 {
    public static void main(String[] args) {
        List<Integer> list=new ArrayList<>();
        for(int i=0;i<3;i++){
            list.add((int)(Math.random()*100));
        }
        System.out.println(list);

        Optional<Integer> value=list.stream().min((o1,o2)->o1-o2);
        System.out.println(value.get());

        boolean anyMatch=list.stream().anyMatch(i->i%2==0);
        System.out.println("是否有偶数："+anyMatch);

        boolean allMatch=list.stream().allMatch(i->i%2==0);
        System.out.println("是否全部是偶数："+allMatch);

        boolean noneMatch=list.stream().noneMatch(i->i%2==0);
        System.out.println("是否没有偶数："+noneMatch);

        int number=list.stream().reduce((e1,e2)->e1+e2).get();
        System.out.println("累加："+number);
    }
}
